12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\youzan\logic;
- use app\admin\model\ActionLog;
- use app\admin\model\GoodLog;
- use app\admin\model\ProcessOrder;
- use app\youzan\model\PlatformYouzan;
- use think\Exception;
- use think\facade\Cache;
- use think\facade\Db;
- //有赞订单类
- class Order
- {
- //获取有赞订单列表
- public static function getYzOrderList(array $data = [])
- {
- if (isset($data['platform_name']) && $data['platform_name'] != '') {
- $data['skuCodes'] = Db::name('platform_youzan')
- ->alias('py')
- ->leftJoin('platform p', 'p.id=py.platform_id AND p.is_del=0')
- ->whereLike('p.platform_name', '%' . $data['platform_name'] . '%')
- ->column('py.skuCode');
- }
- $res = curl_request(config('app.yz_domain') . 'api/yz_order_list', $data);
- $res = json_decode($res, true);
- if ($res['code'] == 0) return app_show(0, $res['message'], $res['data']);
- else return error_show($res['code'], $res['message']);
- }
- //有赞订单审核
- public static function checkStatus(array $data = [])
- {
- if (in_array($data['status'], [3, 5]) && $data['reason'] == '') return error_show(1005, '请填写驳回原因');
- //用户信息
- $userinfo = GetUserInfo($data['token']);
- $uid = isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0;
- $uname = isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '';
- $res = curl_request(config('app.yz_domain') . 'api/yz_check_status', array_merge($data, ['uid' => $uid, 'uname' => $uname]));
- $res = json_decode($res, true);
- if ($res['code'] == 0) {
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $uid, 'nickname' => $uname], [
- "order_code" => $res['data']['skuCode'],
- "status" => $res['data']['old_status'],//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "YZQRD", 0, $data);
- //取符合条件的角色下的所有人
- $action_process_id = Db::name('action_process')
- ->where(['order_type' => 'YZQRD', 'order_process' => $data['status']])
- ->value('id', 0);
- $roleids = Db::name('role_process')
- ->where('is_del', 0)
- ->where('role_id', '<>', 1)//排除超级管理员
- ->whereFindInSet('action_data', $action_process_id)
- ->field('role_id')
- ->buildSql();
- //根据角色id筛选用户id
- $uids = Db::name('user_role')
- ->where(['is_del' => 0, 'status' => 1])
- ->where('roleid IN ' . $roleids)
- ->column('uid');
- ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $uname], [
- "order_type" => 'YZQRD',
- "order_code" => $res['data']['skuCode'],
- "order_id" => $data['id'],
- "order_status" => $data['status'],
- "before_status" => $res['data']['old_status'],
- 'handle_user_list' => implode(',', $uids)
- ]);
- return app_show(0, '操作成功');
- } else return error_show(1005, $res['message']);
- }
- }
|