1
This commit is contained in:
@@ -11,6 +11,27 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ApplyContract 电子合同申请回调
|
||||
func ApplyContract(callback *lakala.ApplyContractCallBack) error {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if callback.Code == "000000" {
|
||||
merchantInfo, err := dao.GetStoreContract(db, 0, callback.RespData.OrderNo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
merchantInfo.ContractStatus = callback.RespData.AuditStatus
|
||||
_, err = dao.UpdateEntity(db, merchantInfo, "ContractStatus")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateSeparateShop 商户分账业务回调(创建/修改)
|
||||
func CreateSeparateShop(callback *lakala.SeparateCallback) error {
|
||||
var (
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -17,14 +16,55 @@ import (
|
||||
|
||||
//#region 进件相关API
|
||||
|
||||
// LaKaLaApplyContract 拉卡拉申请签约合同
|
||||
func LaKaLaApplyContract(ctx *jxcontext.Context, apply *lakala.ApplyContractParam, storeID int) (*lakala.ApplyContractResp, error) {
|
||||
apply.OrderNo = lakala.GetOrderNumber(10)
|
||||
apply.RetUrl = lakala.ApplyContractCallback
|
||||
contractObj, err := api.LaKaLaApi.ApplyElectronicContract(apply)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
incomingObj := &model.LakalaContract{
|
||||
StoreId: storeID,
|
||||
ContractId: contractObj.OrderNo,
|
||||
ContractApplyId: utils.Int64ToStr(contractObj.EcApplyId),
|
||||
ContractStatus: "WAIT_AUDIT ",
|
||||
ApplyType: apply.EcTypeCode,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(incomingObj, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, incomingObj); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return contractObj, nil
|
||||
}
|
||||
|
||||
// QueryElectronicContract 拉卡拉签约合同查询
|
||||
func QueryElectronicContract(orderNo string, orgId int, ecApplyId string, storeID int) (*lakala.ElectronicContractStatus, error) {
|
||||
db := dao.GetDB()
|
||||
merchantInfo, err := dao.GetStoreContract(db, storeID, orderNo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
contractObj, err := api.LaKaLaApi.QueryElectronicContract(orderNo, orgId, ecApplyId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
merchantInfo.ContractStatus = contractObj.AuditStatus
|
||||
dao.UpdateEntity(db, merchantInfo, "ContractStatus")
|
||||
|
||||
return contractObj, nil
|
||||
}
|
||||
|
||||
// LaKaLaInComing 商户进件
|
||||
func LaKaLaInComing(ctx *jxcontext.Context, incoming *lakala.MerchantIncomingReq, storeId int) (string, error) {
|
||||
globals.SugarLogger.Debugf("---------lakala : %s ", utils.Format4Output(incoming, false))
|
||||
merchantNo, status, err := api.LaKaLaApi.MerchantIncoming(incoming)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
globals.SugarLogger.Debugf("---------LaKaLaInComing : %s , %s", merchantNo, status)
|
||||
incomingObj := &model.LakalaIncoming{
|
||||
StoreId: storeId,
|
||||
MerchantNo: merchantNo,
|
||||
@@ -833,4 +873,9 @@ func WithdrawalList(merchantNo, drawJnl, acctName, startTime, endTime string, pa
|
||||
return dao.WithdrawalList(merchantNo, drawJnl, acctName, start, end, pageSize, offset)
|
||||
}
|
||||
|
||||
// QueryApplyContractList 门店合同申请记录
|
||||
func QueryApplyContractList(orderNo string, storeID, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
return dao.QueryApplyContractList(orderNo, storeID, pageSize, offset)
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -5,6 +5,29 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetStoreContract(db *DaoDB, storeId int, orderId string) (*model.LakalaContract, error) {
|
||||
merchantObj := &model.LakalaContract{}
|
||||
param := []interface{}{}
|
||||
sql := ` SELECT * FROM lakala_contract WHERE 1=1`
|
||||
|
||||
if storeId != 0 {
|
||||
{
|
||||
sql += ` AND store_id = ?`
|
||||
param = append(param, storeId)
|
||||
}
|
||||
}
|
||||
|
||||
if orderId != "" {
|
||||
sql += ` AND contract_id = ?`
|
||||
param = append(param, orderId)
|
||||
}
|
||||
if err := GetRow(db, merchantObj, sql, param...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return merchantObj, nil
|
||||
}
|
||||
|
||||
// GetStoreInfoByMerchantID 门店进件/分账商户
|
||||
func GetStoreInfoByMerchantID(db *DaoDB, merchantNo string, storeId int, applyId, OrderID string) (*model.LakalaIncoming, error) {
|
||||
merchantObj := &model.LakalaIncoming{}
|
||||
@@ -284,3 +307,44 @@ func WithdrawalList(merchantNo, drawJnl, acctName string, startTime, endTime tim
|
||||
return pagedInfo, nil
|
||||
|
||||
}
|
||||
|
||||
// QueryApplyContractList 门店合同生气记录
|
||||
func QueryApplyContractList(orderNo string, storeID, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
db := GetDB()
|
||||
txDB, _ := Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
|
||||
var recipient []*model.LakalaContract
|
||||
var param = []interface{}{}
|
||||
sql := ` SELECT SQL_CALC_FOUND_ROWS r.* FROM lakala_contract r WHERE 1=1 `
|
||||
|
||||
if storeID != 0 {
|
||||
sql += ` AND r.store_id = ?`
|
||||
param = append(param, storeID)
|
||||
}
|
||||
if orderNo != "" {
|
||||
sql += ` AND r.contract_id = ? `
|
||||
param = append(param, orderNo)
|
||||
}
|
||||
|
||||
sql += `
|
||||
ORDER BY r.id desc
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
param = append(param, pageSize, offset)
|
||||
|
||||
if err = GetRowsTx(txDB, &recipient, sql, param...); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount2(db, txDB),
|
||||
Data: recipient,
|
||||
}
|
||||
}
|
||||
|
||||
return pagedInfo, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,22 @@ const (
|
||||
CmdTypeFallBack = "FALLBACK" // 分账退回
|
||||
)
|
||||
|
||||
type LakalaContract struct {
|
||||
ModelIDCUL
|
||||
ContractId string `orm:"column(contract_id);size(20)" json:"contractId"` // 订单编号
|
||||
ContractApplyId string `orm:"column(contract_apply_id);size(20)" json:"contractApplyId"` // 电子合同编号
|
||||
ContractStatus string `orm:"column(contract_status);size(20)" json:"ContractStatus"` // 合同状态
|
||||
StoreId int `orm:"column(store_id);size(16)" json:"storeId"` // 京西门店ID
|
||||
ApplyType string `orm:"column(apply_type);size(16)" json:"applyType"` // 申请类型
|
||||
}
|
||||
|
||||
func (o *LakalaContract) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"StoreID"},
|
||||
[]string{"contract_id"},
|
||||
}
|
||||
}
|
||||
|
||||
// LakalaIncoming 进件账户状态,分账状态
|
||||
type LakalaIncoming struct {
|
||||
ModelIDCUL
|
||||
|
||||
@@ -11,6 +11,46 @@ type LaKaLaController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// LaKaLaApplyContract 拉卡拉商户合同申请
|
||||
// @Title 拉卡拉商户合同申请
|
||||
// @Description 拉卡拉商户合同申请
|
||||
// @Param token header string true "认证token"
|
||||
// @Param payload formData string true "json数据,lakala.ApplyContractParam 对象"
|
||||
// @Param storeID formData int true "门店ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /LaKaLaApplyContract [post]
|
||||
func (c *LaKaLaController) LaKaLaApplyContract() {
|
||||
c.callLaKaLaApplyContract(func(params *tLakalaLaKaLaApplyContractParams) (retVal interface{}, errCode string, err error) {
|
||||
contract := &lakala.ApplyContractParam{}
|
||||
err = utils.UnmarshalUseNumber([]byte(params.Payload), contract)
|
||||
if err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
|
||||
retVal, err = lakalaServer.LaKaLaApplyContract(params.Ctx, contract, params.StoreID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// QueryElectronicContract 合同申请状态查询
|
||||
// @Title 合同申请状态查询
|
||||
// @Description 合同申请状态查询
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeID formData int true "门店ID"
|
||||
// @Param orderNo formData string true "订单编号"
|
||||
// @Param orgId formData int true "组织ID"
|
||||
// @Param ecApplyId formData string true "申请ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /QueryElectronicContract [post]
|
||||
func (c *LaKaLaController) QueryElectronicContract() {
|
||||
c.callQueryElectronicContract(func(params *tLakalaQueryElectronicContractParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = lakalaServer.QueryElectronicContract(params.OrderNo, params.OrgId, params.EcApplyId, params.StoreID)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
// MerchantIncoming 拉卡拉商户进件
|
||||
// @Title 创建拉卡拉商户
|
||||
// @Description 创建拉卡拉商户
|
||||
@@ -809,6 +849,24 @@ func (c *LaKaLaController) WithdrawalList() {
|
||||
})
|
||||
}
|
||||
|
||||
// QueryApplyContractList 门店合同申请记录查询
|
||||
// @Title 门店合同申请记录查询
|
||||
// @Description 门店合同申请记录查询
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeId query int false "门店ID"
|
||||
// @Param orderNo query string false "京西订单ID"
|
||||
// @Param offset query int true "列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int true "列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /QueryApplyContractList [get]
|
||||
func (c *LaKaLaController) QueryApplyContractList() {
|
||||
c.callQueryApplyContractList(func(params *tLakalaQueryApplyContractListParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = lakalaServer.QueryApplyContractList(params.OrderNo, params.StoreId, params.PageSize, params.PageSize)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
// GetCardBin 卡BIN查询
|
||||
// @Title 卡BIN查询
|
||||
// @Description 卡BIN查询
|
||||
|
||||
@@ -13,6 +13,27 @@ type LaKaLaCallbackController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// applyContract 合同申请回调
|
||||
func (c *LaKaLaCallbackController) applyContract() {
|
||||
body, err := ioutil.ReadAll(c.Ctx.Request.Body)
|
||||
if err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
apply := &lakala.ApplyContractCallBack{}
|
||||
if err = json.Unmarshal(body, apply); err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
c.Data["json"] = lakala.CallBackResultInfo(lakalaServer.ApplyContract(apply))
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// SeparateMsg 商户开通/修改分账业务回调
|
||||
func (c *LaKaLaCallbackController) SeparateMsg() {
|
||||
body, err := ioutil.ReadAll(c.Ctx.Request.Body)
|
||||
@@ -23,7 +44,7 @@ func (c *LaKaLaCallbackController) SeparateMsg() {
|
||||
}
|
||||
|
||||
separate := &lakala.SeparateCallback{}
|
||||
if err = json.Unmarshal(body, &separate); err != nil {
|
||||
if err = json.Unmarshal(body, separate); err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
@@ -44,7 +65,7 @@ func (c *LaKaLaCallbackController) SeparateBind() {
|
||||
}
|
||||
|
||||
separate := &lakala.SeparateBindCallback{}
|
||||
if err = json.Unmarshal(body, &separate); err != nil {
|
||||
if err = json.Unmarshal(body, separate); err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
@@ -66,7 +87,7 @@ func (c *LaKaLaCallbackController) Separate() {
|
||||
}
|
||||
|
||||
separate := &lakala.SeparateResult{}
|
||||
if err = json.Unmarshal(body, &separate); err != nil {
|
||||
if err = json.Unmarshal(body, separate); err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
@@ -87,7 +108,7 @@ func (c *LaKaLaCallbackController) EwalletWithdrawD1() {
|
||||
}
|
||||
|
||||
separate := &lakala.EwalletWithdrawD1CallBack{}
|
||||
if err = json.Unmarshal(body, &separate); err != nil {
|
||||
if err = json.Unmarshal(body, separate); err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
@@ -108,7 +129,7 @@ func (c *LaKaLaCallbackController) OrderStatus() {
|
||||
}
|
||||
|
||||
separate := &lakala.QueryOrderCallBackResp{}
|
||||
if err = json.Unmarshal(body, &separate); err != nil {
|
||||
if err = json.Unmarshal(body, separate); err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
@@ -133,7 +154,7 @@ func (c *LaKaLaCallbackController) PayStatus() {
|
||||
}
|
||||
|
||||
separate := &lakala.PayStatusCallBack{}
|
||||
if err = json.Unmarshal(body, &separate); err != nil {
|
||||
if err = json.Unmarshal(body, separate); err != nil {
|
||||
c.Data["json"] = lakala.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
|
||||
@@ -134,6 +134,7 @@ func Init() {
|
||||
orm.RegisterModel(&model.StoreAcctOrder{})
|
||||
|
||||
// 拉卡拉分账
|
||||
orm.RegisterModel(&model.LakalaContract{})
|
||||
orm.RegisterModel(&model.LakalaIncoming{})
|
||||
orm.RegisterModel(&model.LakalaRecipient{})
|
||||
orm.RegisterModel(&model.LakalaSeparateAmt{})
|
||||
|
||||
@@ -4690,6 +4690,24 @@ func init() {
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// lakala商户进件合同申请
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"],
|
||||
web.ControllerComments{
|
||||
Method: "LaKaLaApplyContract",
|
||||
Router: `/LaKaLaApplyContract`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// lakala商户进件合同申请审核查询
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"],
|
||||
web.ControllerComments{
|
||||
Method: "QueryElectronicContract",
|
||||
Router: `/QueryElectronicContract`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// lakala商户进件
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"],
|
||||
web.ControllerComments{
|
||||
@@ -5086,6 +5104,15 @@ func init() {
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// 门店合同申请记录查询
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"],
|
||||
web.ControllerComments{
|
||||
Method: "QueryApplyContractList",
|
||||
Router: `/QueryApplyContractList`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// 卡BIN查询
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:LaKaLaController"],
|
||||
web.ControllerComments{
|
||||
|
||||
Reference in New Issue
Block a user