wx cash
This commit is contained in:
@@ -218,7 +218,13 @@ func AcceptJob(ctx *jxcontext.Context, jobID int) (err error) {
|
|||||||
JobID: jobID,
|
JobID: jobID,
|
||||||
JobOrderID: jxutils.GenJobOrderNo(),
|
JobOrderID: jxutils.GenJobOrderNo(),
|
||||||
UserID: job.UserID,
|
UserID: job.UserID,
|
||||||
Status: model.JobOrderStatusAccept,
|
// Status: model.JobOrderStatusAccept,
|
||||||
|
}
|
||||||
|
//美团会员任务
|
||||||
|
if jobID == 1 {
|
||||||
|
jobOrder.Status = model.JobOrderStatusSpec
|
||||||
|
} else {
|
||||||
|
jobOrder.Status = model.JobOrderStatusAccept
|
||||||
}
|
}
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
@@ -60,6 +60,25 @@ func Pay(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func Cash(ctx *jxcontext.Context, orderID int) (err error) {
|
func Cash(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
order = &model.Order{
|
||||||
|
OrderID: int64(orderID),
|
||||||
|
}
|
||||||
|
payHandler = &financial.PayHandler{
|
||||||
|
PayType: payType,
|
||||||
|
Ctx: ctx,
|
||||||
|
VendorPayType: vendorPayType,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
err = dao.GetEntity(db, order, "OrderID")
|
||||||
|
payHandler.Order = order
|
||||||
|
//如果用户没有对应账单信息就给他生成一条
|
||||||
|
userBill, err := dao.GetUserBill(db, order.UserID, "")
|
||||||
|
if userBill == nil {
|
||||||
|
err = financial.AddUserBill(db, jxutils.GenBillID(), order.UserID)
|
||||||
|
}
|
||||||
|
err = payHandler.CreateRefund()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,36 @@ func (p *PayHandler) CreateRefund() (err error) {
|
|||||||
switch p.PayType {
|
switch p.PayType {
|
||||||
case model.PayTypeTL:
|
case model.PayTypeTL:
|
||||||
case model.PayTypeWX:
|
case model.PayTypeWX:
|
||||||
|
//企业付款(提现)
|
||||||
|
if p.VendorPayType == model.VendorPayTypeCompanyPay {
|
||||||
|
param := &wxpayapi.TransfersParam{
|
||||||
|
PartnerTradeNo: utils.Int64ToStr(p.Order.OrderID),
|
||||||
|
CheckName: wxpayapi.CheckName,
|
||||||
|
Amount: p.Order.PayPrice,
|
||||||
|
Desc: "冲天猴儿app提现到账",
|
||||||
|
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
||||||
|
}
|
||||||
|
if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeWxApp {
|
||||||
|
param.OpenID = authInfo.GetAuthID()
|
||||||
|
}
|
||||||
|
result, err := api.WxpayAPI.Transfers(param)
|
||||||
|
if err == nil {
|
||||||
|
p.Order.PayFinishedAt = utils.Str2Time(result.PaymentTime)
|
||||||
|
p.Order.Comment = result.DeviceInfo
|
||||||
|
p.Order.OriginalData = utils.Format4Output(result, true)
|
||||||
|
if result.ReturnMsg == "" {
|
||||||
|
p.Order.Status = model.OrderStatusFinished
|
||||||
|
} else {
|
||||||
|
p.Order.Status = model.OrderStatusCanceled
|
||||||
|
}
|
||||||
|
dao.UpdateEntity(dao.GetDB(), p.Order)
|
||||||
|
if result.ReturnMsg == "" {
|
||||||
|
err = OnPayFinished(p.Order)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -97,7 +127,7 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
|||||||
}
|
}
|
||||||
loc, _ := time.LoadLocation("Local")
|
loc, _ := time.LoadLocation("Local")
|
||||||
t1, _ := time.ParseInLocation("20060102150405", call.PayTime, loc)
|
t1, _ := time.ParseInLocation("20060102150405", call.PayTime, loc)
|
||||||
order.PayFinishedAt = utils.Time2Pointer(t1)
|
order.PayFinishedAt = t1
|
||||||
// order.TransactionID = call.ChnlTrxID
|
// order.TransactionID = call.ChnlTrxID
|
||||||
order.OriginalData = utils.Format4Output(call, true)
|
order.OriginalData = utils.Format4Output(call, true)
|
||||||
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
@@ -197,7 +227,7 @@ func onWxpayFinished(msg *wxpayapi.PayResultMsg) (err error) {
|
|||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
||||||
order.PayFinishedAt = utils.Time2Pointer(wxpayapi.PayTime2Time(msg.TimeEnd))
|
order.PayFinishedAt = wxpayapi.PayTime2Time(msg.TimeEnd)
|
||||||
order.TransactionID = msg.TransactionID
|
order.TransactionID = msg.TransactionID
|
||||||
order.OriginalData = utils.Format4Output(msg, true)
|
order.OriginalData = utils.Format4Output(msg, true)
|
||||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const (
|
|||||||
JobLimitCountTypePWO = 3 //每人每周一次
|
JobLimitCountTypePWO = 3 //每人每周一次
|
||||||
JobLimitCountTypeNoLimit = 4 //不限制
|
JobLimitCountTypeNoLimit = 4 //不限制
|
||||||
|
|
||||||
|
JobOrderStatusSpec = 1
|
||||||
JobOrderStatusAccept = 5
|
JobOrderStatusAccept = 5
|
||||||
JobOrderStatusWaitAudit = 10
|
JobOrderStatusWaitAudit = 10
|
||||||
JobOrderStatusAuditPass = 15
|
JobOrderStatusAuditPass = 15
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ const (
|
|||||||
|
|
||||||
EarningTypeQuote = 1 //报价模式
|
EarningTypeQuote = 1 //报价模式
|
||||||
EarningTypePoints = 2 //扣点模式
|
EarningTypePoints = 2 //扣点模式
|
||||||
|
|
||||||
|
VendorPayTypeCompanyPay = "companyPay" //企业付款
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -447,16 +449,16 @@ func IsAfsOrderJXTemp(order *AfsOrder) bool {
|
|||||||
type Order struct {
|
type Order struct {
|
||||||
ModelIDCUL
|
ModelIDCUL
|
||||||
|
|
||||||
OrderID int64 `orm:"column(order_id)" json:"orderID"` //订单号
|
OrderID int64 `orm:"column(order_id)" json:"orderID"` //订单号
|
||||||
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
||||||
Type int `json:"type"` //订单类型
|
Type int `json:"type"` //订单类型
|
||||||
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
||||||
PayPrice int `json:"payPrice"` //支付金额
|
PayPrice int `json:"payPrice"` //支付金额
|
||||||
TransactionID string `orm:"column(transaction_id);size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
TransactionID string `orm:"column(transaction_id);size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
||||||
PayFinishedAt *time.Time `orm:"type(datetime);null" json:"payFinishedAt"`
|
PayFinishedAt time.Time `orm:"type(datetime);null" json:"payFinishedAt"`
|
||||||
PrepayID string `orm:"column(prepay_id);size(48)" json:"prepayID"` // 下单后,支付前,支付方生成的事务ID
|
PrepayID string `orm:"column(prepay_id);size(48)" json:"prepayID"` // 下单后,支付前,支付方生成的事务ID
|
||||||
OriginalData string `orm:"type(text)" json:"-"`
|
OriginalData string `orm:"type(text)" json:"-"`
|
||||||
Comment string `orm:"size(255)" json:"comment"` //备注
|
Comment string `orm:"size(255)" json:"comment"` //备注
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Order) TableUnique() [][]string {
|
func (v *Order) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -29,12 +29,14 @@ func (c *OrderController) Pay() {
|
|||||||
// @Description 提现
|
// @Description 提现
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param orderID formData int true "订单号"
|
// @Param orderID formData int true "订单号"
|
||||||
|
// @Param payType formData int true "支付平台类型"
|
||||||
|
// @Param vendorPayType formData string true "平台支付类型"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /Cash [post]
|
// @router /Cash [post]
|
||||||
func (c *OrderController) Cash() {
|
func (c *OrderController) Cash() {
|
||||||
c.callCash(func(params *tOrderCashParams) (retVal interface{}, errCode string, err error) {
|
c.callCash(func(params *tOrderCashParams) (retVal interface{}, errCode string, err error) {
|
||||||
err = cms.Cash(params.Ctx, params.Price)
|
err = cms.Cash(params.Ctx, params.OrderID, params.PayType, params.VendorPayType)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user