切换导航条
此项目
正在载入...
登录
李忠强
/
temporaryfood
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
李忠强
3 years ago
提交
210b96d0f40c631c05386923f2edd7e3a44a4baa
1 个父辈
fea9c024
更新
隐藏空白字符变更
内嵌
并排对比
正在显示
10 个修改的文件
包含
109 行增加
和
13 行删除
addons/epay/library/Service.php
application/admin/controller/litestore/Litestoregoods.php
application/admin/controller/litestore/Litestoreorder.php
application/admin/lang/zh-cn/litestore/litestoregoods.php
application/admin/model/litestore/Litestoregoods.php
application/api/controller/Notify.php
application/api/controller/Order.php
application/api/controller/User.php
application/api/model/User.php
public/assets/js/backend/litestore/litestoregoods.js
addons/epay/library/Service.php
查看文件 @
210b96d
...
...
@@ -186,7 +186,7 @@ class Service
* @param array $config 配置信息
* @return bool|\Yansongda\Pay\Gateways\Alipay|\Yansongda\Pay\Gateways\Wechat
*/
public
static
function
checkNotify
(
$type
,
$config
=
[])
public
static
function
checkNotify
(
$type
,
$pay_type
=
'pay'
,
$config
=
[])
{
$type
=
strtolower
(
$type
);
if
(
!
in_array
(
$type
,
[
'wechat'
,
'alipay'
]))
{
...
...
@@ -195,7 +195,11 @@ class Service
try
{
$config
=
self
::
getConfig
(
$type
);
$pay
=
$type
==
'wechat'
?
Pay
::
wechat
(
$config
)
:
Pay
::
alipay
(
$config
);
$data
=
$pay
->
verify
();
if
(
$pay_type
==
'refund'
){
$data
=
$pay
->
verify
(
null
,
true
);
}
else
{
$data
=
$pay
->
verify
();
}
if
(
$type
==
'alipay'
)
{
if
(
in_array
(
$data
[
'trade_status'
],
[
'TRADE_SUCCESS'
,
'TRADE_FINISHED'
]))
{
...
...
application/admin/controller/litestore/Litestoregoods.php
查看文件 @
210b96d
...
...
@@ -63,13 +63,13 @@ class Litestoregoods extends Backend
}
list
(
$where
,
$sort
,
$order
,
$offset
,
$limit
)
=
$this
->
buildparams
();
$total
=
$this
->
model
->
with
([
'category'
])
->
with
([
'category'
,
'activity'
])
->
where
(
$where
)
->
order
(
$sort
,
$order
)
->
count
();
$list
=
$this
->
model
->
with
([
'category'
])
->
with
([
'category'
,
'activity'
])
->
where
(
$where
)
->
order
(
$sort
,
$order
)
->
limit
(
$offset
,
$limit
)
...
...
@@ -78,6 +78,7 @@ class Litestoregoods extends Backend
foreach
(
$list
as
$row
)
{
$row
->
getRelation
(
'category'
)
->
visible
([
'name'
]);
$row
->
getRelation
(
'activity'
)
->
visible
([
'name'
]);
// $row->getRelation('freight')->visible(['name']);
}
$list
=
collection
(
$list
)
->
toArray
();
...
...
application/admin/controller/litestore/Litestoreorder.php
查看文件 @
210b96d
...
...
@@ -2,6 +2,7 @@
namespace
app\admin\controller\litestore
;
use
app\api\model\RiderOrder
;
use
app\common\controller\Backend
;
/**
...
...
@@ -88,6 +89,13 @@ class Litestoreorder extends Backend
$row
[
'rider_user_id'
]
=
input
(
'post.virtual_name'
);
// $row['express_no'] = input('post.virtual_sn');
$row
->
save
();
$param
=
[
'order_id'
=>
$row
->
id
,
'user_id'
=>
input
(
'post.virtual_name'
),
'address_id'
=>
$row
->
address_id
,
'price'
=>
$row
->
express_price
,
];
RiderOrder
::
create
(
$param
);
$this
->
success
();
}
...
...
application/admin/lang/zh-cn/litestore/litestoregoods.php
查看文件 @
210b96d
...
...
@@ -26,6 +26,7 @@ return [
'Createtime'
=>
'创建时间'
,
'Updatetime'
=>
'更新时间'
,
'Category.name'
=>
'分类名称'
,
'Activity.name'
=>
'活动名称'
,
'Freight.name'
=>
'运费模版名称'
,
'Makefor'
=>
'产地'
,
'Makefor 1'
=>
'国产'
,
...
...
application/admin/model/litestore/Litestoregoods.php
查看文件 @
210b96d
...
...
@@ -107,6 +107,12 @@ class Litestoregoods extends Model
return
$this
->
belongsTo
(
'Litestorefreight'
,
'delivery_id'
,
'id'
,
[],
'LEFT'
)
->
setEagerlyType
(
0
);
}
public
function
activity
()
{
return
$this
->
belongsTo
(
'app\admin\model\Activity'
,
'activity_id'
,
'id'
,
[],
'LEFT'
)
->
setEagerlyType
(
0
);
}
/**
* 关联商品规格表
*/
...
...
application/api/controller/Notify.php
查看文件 @
210b96d
...
...
@@ -28,9 +28,11 @@ class Notify extends Api
return
;
}
$data
=
$pay
->
verify
();
$data
=
json_decode
(
$data
,
true
);
$model
=
new
\app\api\model\Order
();
$goodsmodel
=
new
\app\api\model\OrderGoods
();
$skumodel
=
new
\app\api\model\GoodsSpec
();
$goods_model
=
new
\app\api\model\Goods
();
try
{
$out_trade_no
=
$data
[
'out_trade_no'
];
$order
=
$model
...
...
@@ -44,13 +46,16 @@ class Notify extends Api
$order
->
pay_time
=
time
();
$order
->
isUpdate
()
->
save
();
// 减少库存
$sales_actual
=
0
;
$list
=
$goodsmodel
->
where
(
'order_id'
,
$order
[
'id'
])
->
select
();
foreach
(
$list
as
$key
=>
$value
){
$sales_actual
+=
$value
[
'total_num'
];
if
(
$value
[
'deduct_stock_type'
]
==
20
){
$skumodel
->
where
(
'goods_spec_id'
,
$value
[
'goods_spec_id'
])
->
setDec
(
'stock_num'
,
$value
[
'total_num'
]);
}
}
// 增加销量
$goods_model
->
setInc
(
'sales_actual'
,
$sales_actual
);
// 判断是否邀请成功
$user
=
\app\api\model\User
::
get
(
$order
[
'user_id'
]);
if
(
$user
[
'invite_user_id'
]
>
0
&&
$user
[
'invite_status'
]
!=
1
)
{
...
...
@@ -62,4 +67,51 @@ class Notify extends Api
}
echo
$pay
->
success
()
->
send
();
}
/**
* 订单退款回调
*/
public
function
refund
()
{
$paytype
=
$this
->
request
->
param
(
'type'
);
$pay
=
Service
::
checkNotify
(
$paytype
,
'refund'
);
if
(
!
$pay
)
{
echo
'签名错误'
;
return
;
}
$data
=
$pay
->
verify
();
$data
=
json_decode
(
$data
,
true
);
$model
=
new
\app\api\model\Order
();
$goodsmodel
=
new
\app\api\model\OrderGoods
();
$skumodel
=
new
\app\api\model\GoodsSpec
();
$goods_model
=
new
\app\api\model\Goods
();
try
{
$out_trade_no
=
$data
[
'out_refund_no'
];
$order
=
$model
->
where
(
'refund_no'
,
$out_trade_no
)
->
where
(
'pay_status'
,
'20'
)
->
where
(
'order_status'
,
'10'
)
->
find
();
if
(
!
$order
)
$this
->
error
(
'订单不存在'
);
$order
->
refund_id
=
$data
[
'refund_id'
];
$order
->
refund_time
=
time
();
$order
->
order_status
=
'20'
;
$order
->
isUpdate
()
->
save
();
// 增加库存
$sales_actual
=
0
;
$list
=
$goodsmodel
->
where
(
'order_id'
,
$order
[
'id'
])
->
select
();
foreach
(
$list
as
$key
=>
$value
){
$sales_actual
+=
$value
[
'total_num'
];
if
(
$value
[
'deduct_stock_type'
]
==
20
){
$skumodel
->
where
(
'goods_spec_id'
,
$value
[
'goods_spec_id'
])
->
setInc
(
'stock_num'
,
$value
[
'total_num'
]);
}
}
// 减少销量
$goods_model
->
setDec
(
'sales_actual'
,
$sales_actual
);
//你可以在此编写订单逻辑
}
catch
(
Exception
$e
)
{
}
echo
$pay
->
success
()
->
send
();
}
}
\ No newline at end of file
...
...
application/api/controller/Order.php
查看文件 @
210b96d
...
...
@@ -14,6 +14,7 @@ use app\api\model\UserCoupon;
use
app\common\controller\Api
;
use
think\Db
;
use
think\exception\PDOException
;
use
Yansongda\Pay\Pay
;
/**
* 订单
...
...
@@ -539,7 +540,9 @@ class Order extends Api
$order
=
$model
::
get
(
$order_id
);
if
(
!
$order
)
$this
->
error
(
'订单不存在'
);
if
(
$order
[
'receipt_status'
]
==
20
)
$this
->
error
(
'订单已收货,请勿重复提交'
);
if
(
$order
[
'rider_status'
]
==
10
)
$this
->
error
(
'骑手未送达,请稍后提交'
);
$order
->
receipt_status
=
'20'
;
$order
->
receipt_time
=
time
();
$order
->
isUpdate
()
->
save
();
$this
->
success
(
'收货成功'
);
}
...
...
@@ -582,7 +585,21 @@ class Order extends Api
if
(
!
is_numeric
(
$order_id
))
$this
->
error
(
'参数不合法'
);
$model
=
new
\app\api\model\Order
();
$model
->
where
(
'id'
,
$order_id
)
->
isUpdate
()
->
save
([
'order_status'
=>
'20'
]);
$order
=
$model
->
where
(
'id'
,
$order_id
)
->
find
();
if
(
$order
[
'freight_status'
]
==
20
)
$this
->
error
(
'订单已发货无法取消'
);
$config
=
Service
::
getConfig
(
'wechat'
);
$config
[
'notify_url'
]
=
$this
->
request
->
domain
()
.
'api/notify/refund/type/wechat'
;
$config
[
'return_url'
]
=
''
;
$wechat
=
Pay
::
wechat
(
$config
);
$param
=
[
// 'total_fee' => $order['pay_price'],
// 'refund_fee' => $order['pay_price'],
'total_fee'
=>
0.01
,
'refund_fee'
=>
0.01
,
'out_trade_no'
=>
$order
[
'order_no'
],
'out_refund_no'
=>
'LQ-'
.
time
()
.
mt_rand
(
10000
,
99999
)
];
$wechat
->
refund
(
$param
);
$this
->
success
(
'取消成功'
);
}
...
...
application/api/controller/User.php
查看文件 @
210b96d
...
...
@@ -480,18 +480,17 @@ class User extends Api
*/
public
function
inviteReward
()
{
$model
=
new
UserInvitation
();
$model
=
new
\app\api\model\User
();
$coupon
=
Db
::
name
(
'coupon'
)
->
field
(
'price,full_price,endtime'
)
->
find
();
$coupon
[
'endtime'
]
=
date
(
'Y年m月d日'
,
$coupon
[
'endtime'
]);
$coupon
[
'rule'
]
=
Config
::
get
(
'site.invite_rule'
);
$coupon
[
'user_list'
]
=
$model
->
with
([
'user'
])
->
where
(
'user_id'
,
$this
->
auth
->
id
)
->
where
(
'status'
,
'1'
)
$coupon
[
'user_list'
]
=
$model
->
where
(
'invite_user_id'
,
$this
->
auth
->
id
)
->
where
(
'invite_status'
,
'1'
)
->
limit
(
3
)
->
select
();
foreach
(
$coupon
[
'user_list'
]
as
$key
=>
$value
){
$value
->
getRelation
(
'user'
)
->
visible
([
'nickname'
]);
$value
->
visible
([
'user'
]);
$value
->
visible
([
'nickname'
]);
}
$this
->
success
(
'邀请有奖'
,
$coupon
);
}
...
...
application/api/model/User.php
查看文件 @
210b96d
...
...
@@ -13,7 +13,8 @@ class User extends Model
protected
$createTime
=
'createtime'
;
protected
$updateTime
=
'updatetime'
;
protected
$append
=
[
'avatar_text'
'avatar_text'
,
'invite_time_text'
];
public
function
getAvatarTextAttr
(
$value
,
$data
)
...
...
@@ -21,4 +22,10 @@ class User extends Model
$value
=
!
empty
(
$data
[
'avatar'
])
?
cdnurl
(
$data
[
'avatar'
],
true
)
:
''
;
return
$value
;
}
public
function
getInviteTimeTextAttr
(
$value
,
$data
)
{
$value
=
!
empty
(
$data
[
'invite_time'
])
?
date
(
'Y/m/d'
,
$data
[
'invite_time'
])
:
''
;
return
$value
;
}
}
\ No newline at end of file
...
...
public/assets/js/backend/litestore/litestoregoods.js
查看文件 @
210b96d
...
...
@@ -30,6 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','template','litestoreg
{
field
:
'goods_id'
,
title
:
__
(
'Goods_id'
)},
{
field
:
'goods_name'
,
title
:
__
(
'Goods_name'
)},
{
field
:
'category.name'
,
title
:
__
(
'Category.name'
)},
{
field
:
'activity.name'
,
title
:
__
(
'Activity.name'
)},
{
field
:
'category_id'
,
visible
:
false
,
title
:
__
(
'Category_id'
)},
{
field
:
'images'
,
title
:
__
(
'Images'
),
formatter
:
Table
.
api
.
formatter
.
images
},
{
field
:
'spec_type'
,
title
:
__
(
'Spec_type'
),
searchList
:
{
"10"
:
__
(
'Spec_type 10'
),
"20"
:
__
(
'Spec_type 20'
)},
formatter
:
Table
.
api
.
formatter
.
normal
},
...
...
请
注册
或
登录
后发表评论