package handler
import (
cs "aicloud/common/store"
"aicloud/srv/payroll/store"
"golang.org/x/net/context"
)
//1.首先定义接口,所有的策略都是基于一套标准,这样策略(类)才有可替换性。
type IPayChannel interface {
DoPay(channelId, payChargePersonName, payChargePersonIdCardType, payChargePersonIdCardId, payChargePersonMobile string) error
}
type PayChannel struct {
ctx context.Context
db *cs.DB
cycle *store.SalaryCycle
data []*store.SalaryRecord
}
func NewPayChannel() *PayChannel {
return &PayChannel{}
}
func (c *PayChannel) CreatChannelBy(channelType string) IPayChannel {
switch channelType {
case "cmb":
return &Cmb{}
case "zs":
return &Zs{}
default:
//panic("无效渠道")
return nil
}
}
//2.接着两个接口实现类
//招商银行
type Cmb struct {
ctx context.Context
db *cs.DB
cycle *store.SalaryCycle
data []*store.SalaryRecord
}
func (c *Cmb) DoPay(channelId, payChargePersonName, payChargePersonIdCardType, payChargePersonIdCardId, payChargePersonMobile string) error {
//hro具体逻辑
name := c.GetName("dd")
println(name)
return nil
}
func (c *Cmb) GetName(channelId string) string {
//cmb具体逻辑
return channelId + "fffff"
}