| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com
- * =========================================================
- */
- namespace addon\cashier\storeapi\controller;
- use addon\printer\model\PrinterOrder;
- use app\storeapi\controller\BaseStoreApi;
- use addon\cashier\model\Cashier as CashierModel;
- class Cashier extends BaseStoreApi
- {
- /**
- * 交接班
- */
- public function changeShifts()
- {
- $res = (new CashierModel())->changeShifts($this->user_info, $this->site_id, $this->store_id);
- return $this->response($res);
- }
- /**
- * 班次数据
- */
- public function shiftsData()
- {
- $data = [
- 'shifts_data' => (new CashierModel())->getShiftsData($this->site_id, $this->store_id),
- 'userinfo' => [
- 'username' => $this->user_info['username']
- ]
- ];
- return $this->response($this->success($data));
- }
- /**
- * 交接班记录
- */
- public function changeShiftsRecord(){
- $page = $this->params[ 'page' ] ?? 1;
- $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
- $uid = $this->params['uid'] ?? 0;
- $start_time = $this->params['start_time'] ?? '';
- $end_time = $this->params['end_time'] ?? '';
- if (!empty($start_time)) $start_time = strtotime($start_time);
- if (!empty($end_time)) $end_time = strtotime($end_time);
- $condition = [
- [ 'csr.site_id', '=', $this->site_id ],
- [ 'csr.store_id', '=', $this->store_id ],
- ];
- if ($uid != 0) $condition[] = ['csr.uid', '=', $uid];
- if ($start_time && $end_time) {
- $condition[] = [ 'csr.end_time', 'between', [ $start_time, $end_time ] ];
- } elseif (!$start_time && $end_time) {
- $condition[] = [ 'csr.end_time', '<=', $end_time ];
- } elseif ($start_time && !$end_time) {
- $condition[] = [ 'csr.end_time', '>=', $start_time ];
- }
- $join = [ ['user u', 'u.uid = csr.uid', 'left'] ];
- $list = (new CashierModel())->getchangeShiftsPageList($condition, 'csr.*,u.username', 'csr.id desc', $page, $page_size, 'csr', $join);
- return $this->response($list);
- }
- /**
- * 交班打印
- * @return false|string
- */
- public function printTicket()
- {
- $record_id = $this->params['record_id'] ?? 0;
- $printer_order_model = new PrinterOrder();
- $res = $printer_order_model->printer([
- 'type' => 'change_shifts',
- 'site_id' => $this->site_id,
- 'store_id' => $this->store_id,
- 'userinfo' => $this->user_info,
- 'record_id' => $record_id
- ]);
- return $this->response($res);
- }
- /**
- * 获取收银台收款设置
- * @return false|string
- */
- public function getCashierCollectMoneyConfig(){
- $res = (new CashierModel())->getCashierCollectMoneyConfig($this->site_id, $this->store_id);
- return $this->response($res);
- }
- /**
- * 收银台收款设置
- * @return false|string
- */
- public function setCashierCollectMoneyConfig(){
- $data = [
- 'reduction' => $this->params['reduction'] ?? 1,
- 'point' => $this->params['point'] ?? 1,
- 'balance' => $this->params['balance'] ?? 1,
- 'balance_safe' => $this->params['balance_safe'] ?? 0,
- 'sms_verify' => $this->params['sms_verify'] ?? 0,
- 'pay_type' => json_decode($this->params['pay_type'] ?? '[]', true),
- ];
- $res = (new CashierModel())->setCashierCollectMoneyConfig($this->site_id, $this->store_id, $data);
- return $this->response($res);
- }
- }
|