123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- <?php
- // +----------------------------------------------------------------------
- // | likeshop开源商城系统
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | gitee下载:https://gitee.com/likeshop_gitee
- // | github下载:https://github.com/likeshop-github
- // | 访问官网:https://www.likeshop.cn
- // | 访问社区:https://home.likeshop.cn
- // | 访问手册:http://doc.likeshop.cn
- // | 微信公众号:likeshop技术社区
- // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
- // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
- // | 禁止对系统程序代码以任何目的,任何形式的再发布
- // | likeshop团队版权所有并拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeshop.cn.team
- // +----------------------------------------------------------------------
-
- namespace app\common\model\integral;
-
- use app\common\basics\Models;
- use app\common\enum\IntegralGoodsEnum;
- use app\common\enum\IntegralOrderEnum;
- use app\common\enum\PayEnum;
- use app\common\model\user\User;
- use app\common\server\AreaServer;
-
-
- /**
- * 积分订单
- * Class IntegralOrder
- * @package app\common\model\integral
- */
- class IntegralOrder extends Models
- {
- // 设置json类型字段
- protected $json = ['goods_snap'];
-
- // 设置JSON数据返回数组
- protected $jsonAssoc = true;
-
- /**
- * @notes 订单用户
- * @return \think\model\relation\HasOne
- * @author suny
- * @date 2021/7/13 6:48 下午
- */
- public function user()
- {
- return $this->hasOne(User::class, 'id', 'user_id')
- ->field('id,sn,nickname,avatar,level,mobile,sex,create_time');
- }
-
- /**
- * @notes 收货地址
- * @param $value
- * @param $data
- * @return mixed|string
- * @author 段誉
- * @date 2022/3/2 10:33
- */
- public function getDeliveryAddressAttr($value, $data)
- {
- return AreaServer::getAddress([
- $data['province'],
- $data['city'],
- $data['district']
- ], $data['address']);
- }
-
- /**
- * @notes 汇付斗拱参数
- * @param $fieldValue
- * @param $data
- * @return array
- * @author lbzy
- * @datetime 2023-10-23 17:28:25
- */
- function getHfdgParamsAttr($fieldValue, $data)
- {
- return $fieldValue ? ((array) json_decode($fieldValue, true)) : [];
- }
-
- function setHfdgParamsAttr($fieldValue, $data)
- {
- if (is_string($fieldValue)) {
- return $fieldValue;
- }
- return json_encode((array) $fieldValue, JSON_UNESCAPED_UNICODE);
- }
-
-
- /**
- * @notes 按钮
- * @param $value
- * @param $data
- * @return array
- * @author 段誉
- * @date 2022/3/2 9:43
- */
- public function getBtnsAttr($value, $data)
- {
- $goods_snap = $data['goods_snap'];
-
- $btns = [
- 'pay_btn' => $this->getPayBtn($data),
- 'cancel_btn' => $this->getCancelBtn($data, $goods_snap),
- 'delivery_btn' => $this->getDeliveryBtn($data, $goods_snap),
- 'confirm_btn' => $this->getConfirmBtn($data, $goods_snap),
- 'del_btn' => $this->getDelBtn($data),
- ];
- return $btns;
- }
-
-
- /**
- * @notes 是否显示支付按钮
- * @param $data
- * @return int
- * @author 段誉
- * @date 2022/3/2 9:36
- */
- public function getPayBtn($data)
- {
- $btn = 0;
- if ($data['order_status'] == IntegralOrderEnum::ORDER_STATUS_NO_PAID && $data['pay_status'] == PayEnum::UNPAID) {
- $btn = 1;
- }
- return $btn;
- }
-
-
- /**
- * @notes 返回是否显示取消订单按钮
- * @param $data
- * @return int
- * @author 段誉
- * @date 2022/3/2 9:37
- */
- public function getCancelBtn($data, $goods_snap)
- {
- $btn = 0;
- // 积分订单 商品类型为红包时 不可取消
- if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_BALANCE) {
- return $btn;
- }
-
- // 未支付的订单 或 已支付但未发货 可以取消
- if (is_string($data['create_time'])) {
- $data['create_time'] = strtotime($data['create_time']);
- }
- if (($data['order_status'] == IntegralOrderEnum::ORDER_STATUS_NO_PAID && $data['pay_status'] == PayEnum::UNPAID)
- || ($data['pay_status'] == PayEnum::ISPAID && $data['order_status'] == IntegralOrderEnum::ORDER_STATUS_DELIVERY)) {
- $btn = 1;
- }
- return $btn;
- }
-
-
- /**
- * @notes 返回是否显示物流按钮
- * @param $data
- * @return mixed
- * @author 段誉
- * @date 2022/3/2 9:37
- */
- public function getDeliveryBtn($data, $goods_snap)
- {
- // 红包类型 或 商品无需物流
- if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_BALANCE || $goods_snap['delivery_way'] == 0) {
- return 0;
- }
- return $data['shipping_status'];
- }
-
-
- /**
- * @notes 返回是否显示确认收货按钮
- * @param $data
- * @return int
- * @author 段誉
- * @date 2022/3/2 9:37
- */
- public function getConfirmBtn($data, $goods_snap)
- {
- $btn = 0;
-
- // 红包类型 或 订单无需物流
- if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_BALANCE || $goods_snap['delivery_way'] == 0) {
- return $btn;
- }
-
- // 订单待收货 且 已发货状态
- if ($data['order_status'] == IntegralOrderEnum::ORDER_STATUS_GOODS && $data['shipping_status'] == 1) {
- $btn = 1;
- }
- return $btn;
- }
-
-
- /**
- * @notes 返回是否显示删除按钮
- * @param $data
- * @return int
- * @author 段誉
- * @date 2022/3/2 9:37
- */
- public function getDelBtn($data)
- {
- $btn = 0;
- if ($data['order_status'] == IntegralOrderEnum::ORDER_STATUS_DOWN) {
- if ($data['pay_status'] == PayEnum::UNPAID || $data['refund_status'] == 1) {
- $btn = 1;
- }
- }
- return $btn;
- }
-
- /**
- * @notes 兑换类型
- * @param $value
- * @param $data
- * @return string|string[]
- * @author ljj
- * @date 2022/3/2 6:06 下午
- */
- public function getTypeDescAttr($value,$data)
- {
- return IntegralGoodsEnum::getTypeDesc($data['exchange_type']);
- }
-
- /**
- * @notes 订单状态
- * @param $value
- * @param $data
- * @return array|mixed|string|string[]
- * @author ljj
- * @date 2022/3/2 6:16 下午
- */
- public function getOrderStatusDescAttr($value,$data)
- {
- return IntegralOrderEnum::getOrderStatus($data['order_status']);
- }
-
- /**
- * @notes 支付状态
- * @param $value
- * @param $data
- * @return string|string[]
- * @author ljj
- * @date 2022/3/3 11:06 上午
- */
- public function getPayStatusDescAttr($value,$data)
- {
- return PayEnum::getPayStatus($data['pay_status']);
- }
-
- /**
- * @notes 支付方式
- * @param $value
- * @param $data
- * @return array|mixed|string|string[]
- * @author ljj
- * @date 2022/3/3 11:10 上午
- */
- public function getPayWayDescAttr($value,$data)
- {
- return PayEnum::getPayWay($data['pay_way']);
- }
- }
|