123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\shop\logic\express_assistant;
-
-
- use app\common\basics\Logic;
- use app\common\model\Express;
- use app\common\model\face_sheet\FaceSheetTemplate;
- use Exception;
-
-
- class FaceSheetTplLogic extends Logic
- {
-
-
-
- public static function lists($get, $shop_id)
- {
- $where = ['shop_id' => $shop_id];
- $model = new FaceSheetTemplate();
- $count = $model->where($where)->count('id');
- $lists = $model->order('id', 'desc')
- ->where($where)
- ->page($get['page'], $get['limit'])
- ->select();
-
- foreach ($lists as &$item) {
- $item['express'] = Express::where(['id'=>$item['express_id']])->value('name') ?? '未知';
- }
-
- return ['count' => $count, 'lists' => $lists];
- }
-
-
-
-
- public static function detail($id, $shop_id)
- {
- return FaceSheetTemplate::where(['id' => intval($id), 'shop_id' => $shop_id])->find();
- }
-
-
-
-
- public static function add($post, $shop_id)
- {
- try {
- FaceSheetTemplate::create([
- 'shop_id' => $shop_id,
- 'express_id' => $post['express_id'],
- 'name' => $post['name'],
- 'template_id' => $post['template_id'],
- 'partner_id' => $post['partner_id'],
- 'partner_key' => $post['partner_key'],
- 'net' => $post['net'],
- 'pay_type' => $post['pay_type'],
- 'create_time' => time(),
- 'update_time' => time()
- ]);
-
- return true;
- } catch (Exception $e) {
- return $e->getMessage();
- }
- }
-
-
-
-
- public static function edit($post, $shop_id)
- {
- try {
- FaceSheetTemplate::update([
- 'express_id' => $post['express_id'],
- 'name' => $post['name'],
- 'template_id' => $post['template_id'],
- 'partner_id' => $post['partner_id'],
- 'partner_key' => $post['partner_key'],
- 'net' => $post['net'],
- 'pay_type' => $post['pay_type'],
- 'update_time' => time()
- ], ['id' => $post['id'], 'shop_id' => $shop_id]);
-
- return true;
- } catch (Exception $e) {
- return $e->getMessage();
- }
- }
-
-
-
-
- public static function del($id, $shop_id)
- {
- try {
- FaceSheetTemplate::where(['shop_id' => $shop_id, 'id' => $id])
- ->delete();
- return true;
- } catch (Exception $e) {
- return $e->getMessage();
- }
- }
-
-
-
-
- public static function allExpress()
- {
- return Express::where(['del' => 0])->select();
- }
-
-
-
-
- public static function allTpl($shop_id)
- {
- $model = new FaceSheetTemplate();
- return $model->where(['shop_id' => $shop_id])
- ->order('id', 'desc')
- ->select();
- }
-
- }
|