// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\api\service\main\order; use app\common\library\helper; use app\common\service\BaseService; use app\api\model\dealer\Apply as DealerApplyModel; /** * 普通订单支付成功后的回调 * Class PaySuccess * @package app\api\service\main\order */ class PaySuccess extends BaseService { /** * 回调方法 * @param $order * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function onPaySuccess($order): bool { // 购买指定商品成为分销商 $this->becomeDealerUser($order); return true; } /** * 购买指定商品成为分销商 * @param $order * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function becomeDealerUser($order): void { // 整理商品id集 $goodsIds = helper::getArrayColumn($order['goods'], 'goods_id'); $model = new DealerApplyModel; $model->becomeDealerUser((int)$order['user_id'], $goodsIds, $order['store_id']); } }